package com.bjpowernode.service.impl;

import com.bjpowernode.dao.StudentDao;
import com.bjpowernode.domain.Student;
import com.bjpowernode.service.StudentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName StudentServiceImpl
 * @Description
 * @Author hhwu
 * @Date 2022/3/14 9:58
 * Version 1.0
 **/
@Service
public class StudentServiceImpl implements StudentService {
    @Resource//StudentDao.java是接口，StudentDao.xml是其实现类，在spring的配置文件中已经创建了studentDao对象了，这里可以直接注入。
    private StudentDao studentDao;
    @Override
    public int addStudent(Student student) {
        int num = studentDao.insertStudent(student);
        return num;
    }

    @Override
    public List<Student> findStudent() {
        List<Student> students = studentDao.selectStudents();
        return students;
    }

//    @Override
//    public int deleteStudent(int id) {
//        int num = studentDao.deleteStudentById(id);
//        return num;
//    }

    @Override
    public Student findStudentById(int id) {
        Student student = studentDao.selectStudentById(id);
        return student;
    }
}
